package com.sky.controller.admin;


import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminshopController")
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "营业状态相关接口")
public class shopController {

    @Autowired
    private RedisTemplate redisTemplate;


    @ApiOperation("设置营业状态")
    @PutMapping("/{status}")
    public Result setShopStatus(@PathVariable Integer status){
        log.info("设置营业状态：{}",status == 1?"营业中":"打样中" );
        redisTemplate.opsForValue().set("status",status);
        return Result.success();
    }

    @ApiOperation("商家获取店铺的营业状态")
    @GetMapping("/status")
    public Result<Integer> getShopStatus(){
       Integer Status = (Integer) redisTemplate.opsForValue().get("status");
       log.info("当前的营业状态是：{}",Status==1?"当前正在营业":"当前暂停营业");
       return Result.success(Status);
    }
}
